Repository navigation
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #14164 +/- ##
============================================
- Coverage 19.89% 19.89% -0.01%
- Complexity 20144 20149 +5
============================================
Files 6371 6371
Lines 576829 576838 +9
Branches 70627 70629 +2
============================================
- Hits 114778 114769 -9
- Misses 449507 449524 +17
- Partials 12544 12545 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
I came accross this while testing PR #13758 The authorized_keys file was wrong: The newline between the SSH keys wasn't correct. After this commit it now works as expected. |
|
To add, this is how meta_data.json looked in the incorrect format and the correct format: This PR has been tested in real-life with a Ubuntu 26.04 VM using ConfigDrive as it's cloud-init datasource. |
…tadata
An Instance with more than one SSH keypair gets its keys as a single
newline-joined string. The OpenStack meta_data.json builder passed that
string through as one key, so "keys" held a single object and
"public_keys" a single map entry whose value contained both keys with a
newline in between. cloud-init treats every public_keys value as one key
and never splits it, so only the first key worked at best. The name
derived from the third whitespace-separated token could also end up
containing a newline, and the replace("\\n", "") calls stripped a literal
backslash-n rather than a newline and did nothing.
The builder now splits the content on line breaks and emits one "keys"
object and one "public_keys" entry per key. A key is named after its
comment when it has one no earlier key used, otherwise "key" for a lone
key and key0, key1, ... when there are several.
b157e67 to
a08f069
Compare
DaanHoogland
left a comment
There was a problem hiding this comment.
clgtm, just wonder how we can best follow changing open stack standards... 🤔
This standard has not changed, it just originated from OpenStack. We simply did not implement it correctly. |
Description
An Instance with more than one SSH keypair receives its keys as one newline-joined string. The OpenStack
meta_data.jsonbuilder wrote that string as a single key:keysheld one object andpublic_keysone entry whose value contained both keys with a newline in between. cloud-init treats everypublic_keysvalue as one key and never splits it, so only the first key worked at best. Present since multiple SSH keys were introduced in 4.17 (#5965).The builder now emits one
keysobject and onepublic_keysentry per key. A key is named after its comment when it has one that no earlier key used, otherwisekeyfor a single key andkey0,key1, ... for several.Output for an Instance with two keys, the second one with a comment:
{ "keys": [ {"type": "ssh", "data": "ssh-ed25519 AAAA...bsP2", "name": "key0"}, {"type": "ssh", "data": "ssh-ed25519 AAAA...LOn user@laptop", "name": "user@laptop"} ], "public_keys": { "key0": "ssh-ed25519 AAAA...bsP2", "user@laptop": "ssh-ed25519 AAAA...LOn user@laptop" } }Types of changes
Feature/Enhancement Scale or Bug Severity
How Has This Been Tested?
Unit tests added to
ConfigDriveBuilderTestfor a single key, a key with a comment, two keys, duplicate comments with blank lines, and untouched other metadata. Observed on a KVM Instance with two keypairs:meta_data.jsonon the ConfigDrive had both keys in one string and cloud-init installed neither correctly.